/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products.
* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all
* applicable laws, including copyright laws. 
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT.  ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY
* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR
* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability 
* of this software. By using this software, you agree to the additional terms and conditions found by accessing the 
* following link:
* http://www.renesas.com/disclaimer
*
* Copyright (C) 2018, 2022 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/

/***********************************************************************************************************************
* File Name        : Pin.h
* Version          : 1.0.0.0
* Device(s)        : R7F702300
* Description      : This file implements SMC pin code generation.
***********************************************************************************************************************/

#ifndef PIN_H
#define PIN_H

/***********************************************************************************************************************
Macro definitions (Register bit)
***********************************************************************************************************************/

/***********************************************************************************************************************
Macro definitions
***********************************************************************************************************************/

/* User's guide for symbolic name.
 * The generated symbolic names can be used in the user application as follows:
 *
 * Example: Toggle LED1 at Pin P5_4.
 *  There are 2 ways to toggle LED1
 *   1) Using symbolic name macro
 *    Assuming the symbolic name for P5_4 is "LED1", the generated macro definition will be:
 *         #define LED1    5,4
 *
 *    To use this macro definition to toggle the LED1, call the symbolic name APIs:
 *         PIN_WRITE(LED1) = ~PIN_READ(LED1)
 *
 *   2) Not using symbolic name macro
 *    Call the symbolic name APIs directly
 *         PIN_WRITE(5,4) = ~PIN_READ(5,4)
 */

/* Pin write helper */
#define PIN_WRITE_HELPER(x,y)                    ((PORT0.P##x##.BIT.P##x##_##y))
/* Pin read helper */
#define PIN_READ_HELPER(x,y)                     ((PORT0.PPR##x##.BIT.PPR##x##_##y))

/* Pin write API */
#define PIN_WRITE(...)                           (PIN_WRITE_HELPER(__VA_ARGS__))
/* Pin read API */
#define PIN_READ(...)                            (PIN_READ_HELPER(__VA_ARGS__))

/* Port Control Register Default Value (PCR_DEFAULT) */
#define _PCR_DEFAULT_VALUE                        (0x5B5CE000UL) /* Default Value */
/* Analog Input Mode Selection (PCR_ANALOG) */
#define _PCR_ANALOG_INPUT                         (0x00000010UL) /* Analog input */
/* Alternative Mode Selection (ALT_MODE) */
#define _PCR_ALT_IN1                              (0x00000050UL) /* Alternative input mode 1 */
#define _PCR_ALT_IN2                              (0x00000051UL) /* Alternative input mode 2 */
#define _PCR_ALT_IN3                              (0x00000052UL) /* Alternative input mode 3 */
#define _PCR_ALT_IN4                              (0x00000053UL) /* Alternative input mode 4 */
#define _PCR_ALT_IN5                              (0x00000054UL) /* Alternative input mode 5 */
#define _PCR_ALT_IN6                              (0x00000055UL) /* Alternative input mode 6 */
#define _PCR_ALT_IN7                              (0x00000056UL) /* Alternative input mode 7 */
#define _PCR_ALT_IN8                              (0x00000057UL) /* Alternative input mode 8 */
#define _PCR_ALT_OUT1                             (0x00000040UL) /* Alternative output mode 1 */
#define _PCR_ALT_OUT2                             (0x00000041UL) /* Alternative output mode 2 */
#define _PCR_ALT_OUT3                             (0x00000042UL) /* Alternative output mode 3 */
#define _PCR_ALT_OUT4                             (0x00000043UL) /* Alternative output mode 4 */
#define _PCR_ALT_OUT5                             (0x00000044UL) /* Alternative output mode 5 */
#define _PCR_ALT_OUT6                             (0x00000045UL) /* Alternative output mode 6 */
#define _PCR_ALT_OUT7                             (0x00000046UL) /* Alternative output mode 7 */
#define _PCR_ALT_OUT8                             (0x00000047UL) /* Alternative output mode 8 */
/* Direct I/O Alternative Mode Selection (DIRECT_ALT_MODE) */
#define _PCR_DIRECT_ALT_MODE1                     (0x00000060UL) /* Direct I/O mode 1 */
#define _PCR_DIRECT_ALT_MODE2                     (0x00000061UL) /* Direct I/O mode 2 */
#define _PCR_DIRECT_ALT_MODE3                     (0x00000062UL) /* Direct I/O mode 3 */
#define _PCR_DIRECT_ALT_MODE4                     (0x00000063UL) /* Direct I/O mode 4 */
#define _PCR_DIRECT_ALT_MODE5                     (0x00000064UL) /* Direct I/O mode 5 */
#define _PCR_DIRECT_ALT_MODE6                     (0x00000065UL) /* Direct I/O mode 6 */
#define _PCR_DIRECT_ALT_MODE7                     (0x00000066UL) /* Direct I/O mode 7 */
#define _PCR_DIRECT_ALT_MODE8                     (0x00000067UL) /* Direct I/O mode 8 */
/* Specify input/output mode of the corresponding pin (SET_PM) */
#define _PCR_SET_PM                               (0x00000010UL) /* Input mode */
/* Specify input/output mode of the corresponding pin (CLEAR_PM) */
#define _PCR_CLEAR_PM                             (0xFFFFFFEFUL) /* Input mode */
/* Specify the operation mode of the corresponding pin: (SET_PMC) */
#define _PCR_SET_PMC                              (0x00000040UL) /* Alternative mode */
/* For I/O Alternative Mode, PBDC/PIBC setting (DIRECT_ALT_SETTING) */
#define _PCR_ALT_OUT_SETTING                      (0xFFFCFFFFUL) /* ALT Output setting */
#define _PCR_DIRECT_ALT_MODE_SETTING              (0xFFFCFFFFUL) /* Direct ALT mode setting */
/* Write protected macro definition */
#define _WRITE_PROTECT_ENABLE                     (0xA5A5A501UL)  /* Write protected */
#define _WRITE_PROTECT_DISABLE                    (0xA5A5A500UL)  /* Write protected */
#define _PORT_WRITE_PROTECT_DISABLE               (0x00000000UL)  /* Write protected */
#define SETBIT(x)                                 (1U << x)

/***********************************************************************************************************************
Typedef definitions
***********************************************************************************************************************/

/***********************************************************************************************************************
Global functions
***********************************************************************************************************************/
void R_Pins_Create(void);
/* Start user code for function. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
#endif
